package com.xzr;

import java.util.Random;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        int r = 0;
        Scanner n = new Scanner(System.in);
        int number1 = n.nextInt();
        int number2 = n.nextInt();
        while((r = number1%number2)!=0){
            number1= number2;
            number2 = r;
        }
        System.out.println(number2);
    }
    public static void main14(String[] args) {
        Scanner n = new Scanner(System.in);
        int number = n.nextInt();
        int c = 0;
        while(number!=0){
            if(number % 2 == 1){
                c++;
            }
            number = number /2 ;
        }
        System.out.println(c);
    }
    public static void main13(String[] args) {
        Scanner n = new Scanner(System.in);
        int number = n.nextInt();
            int flag = 1;
            for (int j = 2; j < number; j++) {
                if(number % j == 0){
                    flag = 0;
                    break;
                }
            }
            if(flag == 1){
                System.out.print(number + "是素数");
            }else {
                System.out.print(number + "不是素数");
            }

            }


    public static void main12(String[] args) {
            int c = 0;
            for (int year = 1000; year <= 2000 ; year++) {
                if(year % 400 == 0 ||(year % 100 != 0 && year % 4 ==0)){
                    c++;
                    System.out.print(year + " ");
                    if(c%20 == 0){
                        System.out.println();
                    }
                }

            }


    }


    public static void main11(String[] args) {
        int count = 0;
        for (int i = 0; i <=100 ; i++) {
            if( i % 10 == 9 || i /10 == 9){
                System.out.print(i + " ");
                count++;
            }

        }
        System.out.println();
        System.out.println(count);
    }
    public static void main10(String[] args) {
    //打印1-100之间所有的素数

        for (int i = 2; i <=100; i++) {
            int flag = 1;
            for (int j = 2; j < i; j++) {
                if(i % j == 0){
                    flag = 0;
                    break;
                }
            }
            if(flag == 1){
                System.out.print(i + " ");
            }

        }
    }
    public static void main9(String[] args) {
        Random random = new Random();
        int number = random.nextInt(100);//[0,100)
        int number1 = random.nextInt(50)+50;//[50,100)

        double n = Math.random();
        System.out.println(n);
    }
    public static void main8(String[] args) {
        //猜数字游戏
        Scanner scanner = new Scanner(System.in);
        Random random = new Random();
        int number = random.nextInt(100);
        while(true){
            System.out.println("输入所猜数字：>");
            int cai = scanner.nextInt();

            if(cai < number){
                System.out.println("猜的数小了!");
            }else if(cai==number){
                    System.out.println("你猜对了！");
                    break;
            }else{
                System.out.println("猜的数大了！");
            }

        }
    }
    public static void main7(String[] args) {
        //随机数
        Random random = new Random();
        int r = random.nextInt(100);//[0,100)
        System.out.println(r);
    }
    public static void main6(String[] args) {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNextInt()){
            int n = scan.nextInt();
            System.out.println("n = "+n);
        }
    }
    public static void main5(String[] args) {
        Scanner scan = new Scanner(System.in);

        //遇到空格不结束
        String name = scan.nextLine();

        //遇到空格就结束
        String name1 = scan.next();

        int n = scan.nextInt();
        float f = scan.nextFloat();

        System.out.println(name);
        System.out.println(n);
        System.out.println(f);

        scan.close();
    }
    public static void main4(String[] args) {
        int sum = 0;
        for (int i = 1; i <= 5; i++) {
            int ret = 1;
            for (int j = 1; j <=i ; j++) {
                ret *= j;
            }
            sum += ret;
        }
        System.out.println(sum);
    }
    //找到1-100内，既能被3整除，也能被5整除的数字，要求：使用break或者continue当中的一个
    public static void main3(String[] args) {
        int i= 0;
        while(i<=100){
            if(i%15!=0){
                i++;
                continue;
            }
            System.out.println(i);
            i++;
        }
    }
    //求阶乘的逻辑
    public static void main2(String[] args) {
        int i = 1;
        int sum = 0;
        while(i <= 5){
            int a = 1;
            int ret = 1;
            while(a<=i){
                ret *= a;
                a++;
            }
            sum += ret;
            i++;
        }
        System.out.println(sum);
    }


    public static void main1(String[] args) {
    int year = 2021;
    if(year % 400 == 0 ||(year % 100 != 0 && year % 4 ==0)){
        System.out.println(year+"是闰年");
    }else {
        System.out.println(year + "不是闰年");

    }
    }
}
